//
//  CustomWebViewController.m
//  yigou
//
//  Created by wangdianlei on 2017/2/10.
//  Copyright © 2017年 hanyiwang. All rights reserved.
//

#import "CustomWebViewController.h"

@interface CustomWebViewController () <UIWebViewDelegate>

@property (weak, nonatomic) IBOutlet UIWebView *webView;

@end

@implementation CustomWebViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    UIBarButtonItem *backBtn = [ViewFactory makeNavigationBack:self action:@selector(goPop)];
    self.navigationItem.leftBarButtonItem = backBtn;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [ViewFactory setNavigationWhite:self];
    
    self.webView.delegate = self;
    [self.webView setUserInteractionEnabled:YES];//是否支持交互
    [self.webView setScalesPageToFit:YES];//自动缩放以适应屏幕
    [self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:self.url]]];
}

- (void)goPop {
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)webViewDidStartLoad:(UIWebView *)webView {
    [ViewFactory showLoadingEnableTouch];
}

- (void)webViewDidFinishLoad:(UIWebView *)webView {
    [ViewFactory dismissLoading];
}

- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
    [ViewFactory showErrorStrMsg:@"加载失败！"];
}

@end
